<?php
	include '../conn/conn.php';
//	include '../isLogin_json.php';
if (!empty($_POST)) {
	$categoryNo = $_POST['categoryNo'];
	$author = $_POST['author'];
	$title = $_POST['title'];
	$open= $_POST['open'];
	$keywords = $_POST['keywords'];
	$body = $_POST['body'];
	$clicked = $_POST['clicked'];
	$NewsImg = $_POST['NewsImg'];
	$publishTime = gmdate("Y-m-d H:i:s", time() + 8 * 3600);
	$modifyTime = gmdate("Y-m-d H:i:s", time() + 8 * 3600);
	$check_sql = "select * from tb_news where title='$title' and body ='$body' ";
	$check_result = mysqli_query($link, $check_sql);
	$check_new = mysqli_num_rows($check_result);
	
	if ( $check_new > 0 ) {	echo    '{"status":false,"data":"内容重复！"}';
		exit ;

	} else {
		$insert_sql = "insert into tb_news(categoryNo,title,keywords,body,author,publishTime,clicked,NewsImg,modifyTime) values('" . $categoryNo . "','" . $title . "','" . $keywords . "','" . $body . "','" . $author . "','" . $publishTime . "','". $clicked. "','". $NewsImg. "','". $modifyTime. "')";
		$result = mysqli_query($link, $insert_sql);
//var_dump($insert_sql);
		if ($result) {
			  echo '{"status":true,"data":"添加成功！"}';
		} else {
			 echo '{"status":false,"data":"添加失败！"}';
		}
	}
}
?>